var tbody = document.getElementById('tbody')
var ye = document.getElementsByClassName('ye')[0]
var shu =document.getElementsByClassName('shu')[0]
var di =document.getElementsByClassName('di')
var qian =document.getElementsByClassName('qian')
var pb =1
var pp = 0
var sf = '嗯'
bo()
function bo(){
    xhr({
        url:'visitors?page='+pb+'&pageSize=15',
        success:function(qw){
            console.log(qw)
            qq(qw)
            shu.innerHTML= pb
            for(var j =0;j<qw.length;j++){
                if(qw[j].canAcceptCall=true){
                    sf='是'
                }else{
                    sf='否'
                }
                tbody.innerHTML+='<tr><td>'+qw[j].name+'</td><td>'+ qw[j].location+'</td><td>'+qw[j].phone+'</td><td>'+qw[j].time+'</td><td><div class=di onclick=en('+qw[j].id+','+j+')><div class=qian></div></div></td><td>'+sf+'</td></tr>'
                if(qw[j].isRevisited==true){
                    di[j].style.background='green'
                    qian[j].style.margin='0 0 0 10px'
                }
            }
        }
    })
}
function qq(qw){
}
function shang(){
    pb-=1
    if(pb==0){
        pb=1
    }
    shu.innerHTML= pb
    tbody.innerHTML=''
    bo()
    console.log(pb)
}
function xia(){
    pb+=1
    shu.innerHTML= pb
    tbody.innerHTML=''
    bo()
}
function en(id,j){
    console.log(id,j)
    if(di[j].style.background=='green'){
        // di[j].style.background='#777'
        // qian[j].style.margin='0 0 0 0'
    }else{
        di[j].style.background='green'
        qian[j].style.margin='0 0 0 10px'
        xhr({
            methods:'PATCH',
            url:'visitors/'+id,
            success:function(qw){
                console.log(qw)
            }
        })
    }
}